package com.yundasys.lab17.lab17springbootdemo.config;

import com.yundasys.lab17.lab17springbootdemo.entity.Computer;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.FactoryBean;
import org.springframework.stereotype.Component;

/**
 * @Title: ComputerFactoryBean
 * @Description:
 * @author: jiangta
 * @date: 2023/8/24 1:26 下午
 * @Version: 1.0
 */
@Component
@Slf4j
public class ComputerFactoryBean implements FactoryBean {
    private String name = "ComputerFactoryBean本尊";

    public ComputerFactoryBean() {
        log.info("----ComputerFactoryBean无参数构造方法触发执行");
    }

    @Override
    public Object getObject() throws Exception {
        log.info("----com.fanfu.bean.ComputerFactoryBean.getObject()触发执行-start");
        Computer computer = new Computer("商用笔记本电脑");
        log.info("----com.fanfu.bean.ComputerFactoryBean.getObject()触发执行-end");
        return computer;
    }

    @Override
    public Class<?> getObjectType() {
        return Computer.class;
    }

    @Override
    public boolean isSingleton() {
        return true;
    }
}